package config

import "github.com/spf13/viper"

type Config struct {
	viper  *viper.Viper
	Sc     *ServerConf
	Gc     *GrpcConf
	Ec     *EtcdConf
	Mc     *MysqlConf
	Jc     *JwtConf
	Dc     *DbConf
	Kc     *KafkaConf
	Jaeger *JaegerConf
}

type ServerConf struct {
	Name string `yaml:"" json:"name"`
	Addr string `yaml:"" json:"addr"`
}

type GrpcConf struct {
	Name     string `yaml:"name" json:"name"`
	Addr     string `yaml:"addr" json:"addr"`
	EtcdAddr string `yaml:"etcd_addr" json:"etcd_addr"`
	Version  string `yaml:"version" json:"version"`
	Weight   string `yaml:"weight" json:"weight"`
}

type EtcdConf struct {
	Addrs []string `json:"addrs"`
}

type MysqlConf struct {
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
	Host     string `yaml:"host" json:"host"`
	Port     int32  `yaml:"port" json:"port"`
	Db       string `yaml:"db" json:"db"`
	Name     string `yaml:"name" json:"name"`
}

type JwtConf struct {
	AccessExp     int64  `yaml:"access_exp" json:"access_exp"`
	RefreshExp    int64  `yaml:"refresh_exp" json:"refresh_exp"`
	AccessSecret  string `yaml:"access_secret" json:"access_secret"`
	RefreshSecret string `yaml:"refresh_secret" json:"refresh_secret"`
}

type DbConf struct {
	Master     MysqlConf   `yaml:"master" json:"master"`
	Slave      []MysqlConf `yaml:"slave" json:"slave"`
	Separation bool        `yaml:"separation" json:"separation"`
}

type KafkaConf struct {
	Addr  []string `yaml:"addr" json:"addr"`
	Group string   `yaml:"group" json:"group"`
	Topic string   `yaml:"topic" json:"topic"`
}

type JaegerConf struct {
	Endpoints string `yaml:"endpoints" json:"endpoints"`
}
